package cn.xorange.commons.file.entity;

import com.alibaba.fastjson2.JSONObject;
import lombok.Getter;
import lombok.extern.slf4j.Slf4j;

import java.io.Serializable;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Objects;

@Getter
@Slf4j
public class FileBean extends JSONObject{

    FileBean(FileCode fileCode){
        super.put("status", fileCode.getStatus());
        super.put("code", fileCode.getCode());
        super.put("msg", fileCode.getMsg());
    }

    /**
     * 文件上传成功类
     * param path
     * return
     */
    public static FileBean onSuccess(String path){
        FileBean obj = new FileBean(FileCode.SUCCESS);
        obj.put("data",path);
        return obj;
    }

    public static FileBean onSuccess(){
        return new FileBean(FileCode.SUCCESS);
    }

    public static JSONObject onFail(FileCode fileCode){
        return new FileBean(fileCode);
    }




}
